import { useEnum } from '@/enum'
export function useOptions() {
  // 枚举字典
  const orderStateOption = useEnum('orderStateOption')

  const abc = orderStateOption.useEnumItem(2)

  const columns = ref<ColumnsInterface[]>([
    {
      type: 'seq',
    },
    {
      type: 'radio',
    },
    {
      title: '姓名',
      field: 'name',
      width: 120,
      type: 'slot',
      slotName: 'name',
    },
    {
      title: '性别',
      field: 'sex',
      type: 'slot',
      slotName: 'sex',
    },
    {
      title: '订单状态',
      field: 'orderState',
      type: 'slot',
      slotName: 'orderState',
    },
    {
      title: '年级',
      field: 'level',
    },
  ])

  const buttonsArray = ref<ButtonInterface[]>([
    {
      key: 'add',
      label: '添加',
      type: 'primary',
      change: () => {
        alert(3323)
      },
      // 执行之前
      beforeChange: () => {
        return new Promise<void>((resolve, reject) => {
          setTimeout(() => {
            resolve()
          }, 1000)
        })
      },
    },
    {
      key: 'export',
      label: '导出',
      beforeChange: () => {
        return new Promise<void>((resolve, reject) => {
          setTimeout(() => {
            resolve()
          }, 1000)
        })
      },
    },
  ])

  const searchControl = ref<SearchFormInterface[]>([
    {
      type: 'input',
      field: 'orderNo',
      width: '400px',
    },
    {
      type: 'select',
      field: 'orderState',
      width: '150px',
      multiple: true,
      options: orderStateOption.useEnumList(),
    },
  ])

  return {
    columns,
    buttonsArray,
    searchControl,
    // 枚举
    orderStateOption,
  }
}
